<?php

/**
 * @author Martin Pernica
 * @copyright 2009
 */

class Text
{

    static $raw = true;

    /**
     * Text::h1()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function h1($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<h1" . $id . $class . $style . ">" . $text . "</h1>");
    }

    /**
     * Text::h2()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function h2($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<h2" . $id . $class . $style . ">" . $text . "</h2>");
    }

    /**
     * Text::h3()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function h3($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<h3" . $id . $class . $style . ">" . $text . "</h3>");
    }

    /**
     * Text::h4()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function h4($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<h4" . $id . $class . $style . ">" . $text . "</h4>");
    }

    /**
     * Text::h5()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function h5($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<h5" . $id . $class . $style . ">" . $text . "</h5>");
    }

    /**
     * Text::strong()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function strong($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<strong" . $id . $class . $style . ">" . $text . "</strong>");
    }

    /**
     * Text::em()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function em($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<em" . $id . $class . $style . ">" . $text . "</em>");
    }

    /**
     * Text::strike()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function strike($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<strike" . $id . $class . $style . ">" . $text . "</strike>");
    }

    /**
     * Text::cite()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function cite($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<cite" . $id . $class . $style . ">" . $text . "</cite>");
    }

    /**
     * Text::code()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function code($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<code" . $id . $class . $style . ">" . $text . "</code>");
    }

    /**
     * Text::p()
     * 
     * @param mixed $text
     * @param mixed $class
     * @param mixed $id
     * @param mixed $style
     * @return
     */
    public static function p($text, $class = null, $id = null, $style = null)
    {
        $id = (empty($id)) ? '' : ' id="' . $id . '" ';
        $class = (empty($class)) ? '' : ' class="' . $class . '" ';
        $style = (empty($style)) ? '' : ' style="' . $style . '" ';

        self::_output("\n<p" . $id . $class . $style . ">" . $text . "</p>");
    }

    /**
     * Text::br()
     * 
     * @return
     */
    public static function br()
    {
        self::_output("\n<br />");
    }

    /**
     * Text::_output()
     * 
     * @param mixed $text
     * @return
     */
    private static function _output($text)
    {
        if (self::$raw) {
            echo $text;
        } else {
            return $text;
        }
    }

    public static function setOutput($type)
    {
        switch ($type) {
            case 0:
                self::$raw = false;
                break;

            case 1:
                self::$raw = true;
                break;
        }
    }
}

?>